<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
Ext.onReady(function() {
	
	Ext.QuickTips.init();
	
	Ext.define('User', { 
        extend: 'Ext.data.Model', 
        // fields定义字段和数据类型 
        fields: ['id', 'username', 'password','displayName','sex','status'] 
    });
	
	Ext.define('Secuit', {
		extend: 'Ext.data.Model',
		fields: ['id','displayName','phont','EMail','age','visitTime','school']
	});
	
	var userstore=Ext.create('Ext.data.Store', {
        model: 'User', 
        autoLoad: true,
        //使用ajax代理 
        proxy: { 
            type: 'ajax', 
            url: '../service/user_alluser',
            //Reader 解码json数据 
            reader: { 
                type: 'json', 
                root: 'root', 
                total: 'total'
            }
        }
    });
	
	var secuitstore=Ext.create('Ext.data.Store', {
		model: 'Secuit',
		autoload: true,
		proxy: {
			type: 'ajax',
			url: '../service/secuit_allSecuit',
			reader: {
				type: 'json',
				root: 'root',
				total: 'total'
			}
		}
	});
	
	var addreserveform=Ext.widget({
		 	xtype: 'form',
	        layout: 'form',
	        renderTo:'addreserve',
	        frame:true,
	        fieldDefaults: {
	            msgTarget: 'qtip',
	            labelWidth: 80
	        },
	        defaultType: 'textfield',
	        items: [{
	            fieldLabel: '老师',
	            xtype:'combobox',
	            store:userstore,
	            valueField:'id',
	            editable:false,
	            displayField: 'displayName',
	            name: 'userid',
	            allowBlank: false
	        },{
	            fieldLabel: '学生',
	            xtype:'combobox',
	            store:secuitstore,
	            valueField:'id',
	            editable:false,
	            displayField: 'displayName',
	            name: 'secuitid',
	            allowBlank: false
	        },{
	        	id:'phone',
	            fieldLabel: '电话',
	            name: 'reserve.phone',
	            allowBlank: false
	        },{
	        	id:'reserveTime',
	            fieldLabel: '预约时间',
	            xtype: 'datefield',
                format: 'Y-m-d', 
	            name: 'reserve.reserveTime',
	            allowBlank: false
	        }],

       buttons: [{
           text: '保存',
           handler: function() {
        	   this.up('form').getForm().submit({  
                   url : '../service/reserve_add',//请求的url地址  
                   method:'post',//请求方式
                   success:function(form,action){//加载成功的处理函数  
	                   	Ext.Msg.alert('提示', action.result.msg);
	                   	this.up('form').getForm().reset();
              		},
                   failure:function(form,action){//加载成功的处理函数  
 		        		Ext.Msg.alert('提示', action.result.msg); 
  		        	}
               });
       		}
       },{
       	text: '重置',
           handler: function() {
           	this.up('form').getForm().reset();
           }
       }]
   });
});
</script>
</head>
<body>
<div id="addreserve"></div>
</body>
</html>